cv=cv2.VideoCapture(r"./使用IIF函数.mp4")
if cv.isOpened(): #判断VC视频是否正确打开
open_1,frame=cv.read() #读取每一帧视频,返回1是读取是否有内容,False表示读取结束,open_1表行帧序号,frame 表示读取的内容
print(open_1,frame)
else:
open_1=False
while open_1:
open_1,frame=cv.read()
print(open_1)
print(frame)
if frame is None:
break
if open_1==True:
gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) #图像从一种颜色空间转成另一种颜色空间
cv2.imshow("result",gray)
if cv2.waitKey(100)==27: #获取键盘的ACSII码
break